import Vue from 'vue'
import Vuex from 'vuex'
import { apiGetUserInfo } from '@/api/login'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: ''
  },
  mutations: {
    setUserInfo (state, payload) {
      state.userInfo = payload
    }
  },
  actions: {
    async setUserInfo (context) {
      const res = await apiGetUserInfo()
      res.data.avatar = 'http://localhost:1337' + res.data.avatar
      context.commit('setUserInfo', res.data)
    }
  },
  modules: {}
})
